package time.code.added;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;

/**
 * Description: LocalDateTime示例
 *
 * @author code-worker
 * @date 2021/08/22 13:43
 */
public class LocalDateTimeDemo {

    /**
     * task: 获取当前时间
     * @date 2021/8/22 13:45
     */
    public void getDateTime(){
        LocalDateTime now = LocalDateTime.now();
        System.out.println("当前时间: "+now);
    }

    /**
     * task: 获取其他时区时间
     * @date 2021/8/22 19:47
     */
    public void getUsDateTime(){
        ZoneId america = ZoneId.of("America/New_York");
        LocalDateTime nowCn = LocalDateTime.now();
        ZonedDateTime nowUs = ZonedDateTime.of(nowCn, america);
        System.out.println("当前美国纽约时间: "+nowUs);
    }

    public static void main(String[] args) {
        LocalDateTimeDemo demo = new LocalDateTimeDemo();
        demo.getDateTime();
        demo.getUsDateTime();
    }

}
